Description
Allows the user to select a color, displays the RGB values of the selected color, and displays a rectangle filled with selected color on the screen.
VBScript Code
Copy Code | |
---|---|
Sub SymbolColor 'Create a symbol object Dim pSymbol Set pSymbol = Application.CreateAppObject("Symbol") 'Construct a default color of purple Dim lngDefaultColor lngDefaultColor = pSymbol.MakeColor(255,0,255) 'Get a color from the user, using purple as the default Dim varSelColor varSelColor = CommonDialog.ShowColor (lngDefaultcolor) 'Display RGB components of the selected color MsgBox "RGB components of your selected color:" & vbCrlf & _ "Red: " & pSymbol.GetRed(varSelColor) & vbCrlf & _ "Green: " & pSymbol.GetGreen(varSelColor) & vbCrlf & _ "Blue: " & pSymbol.GetBlue(varSelColor),vbInformation,"RGB" 'Create a rectangle to draw on the screen Dim pRect Set pRect = Map.Extent pRect.ScaleRectangle 0.3 'Set the symbol's fill color to the color selected by the user pSymbol.FillColor = varSelColor pSymbol.FillStyle = 0 'Draw the rectangle Map.DrawShape pRect, pSymbol End Sub |